﻿using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;

namespace Adams.Admin.Presentation.Controllers
{
    [Authorize]
    [EnsureSsl]
    public class SitemapController : Controller
    {
        [AppendLayoutViewModel]
        public ActionResult Index()
        {
            var model = Business.Sitemap.Index.PageLoad();
            ViewBag.Message = Request["msg"];
            return View(model);
        }

        public JsonResult Update(Adams.Admin.DataTransfer.Sitemap.Index.UpdateInput input)
        {
            Business.Sitemap.Index.Update(input);
            return Json( new { success = 1} );
        }

        public JsonResult GetNode(Adams.Admin.DataTransfer.Sitemap.Index.GetNodeInput input)
        {
            var model = Business.Sitemap.Index.GetNode(input);
            return Json(model);
        }

        public JsonResult SaveNode(Adams.Admin.DataTransfer.Sitemap.Index.NodeFormInput input)
        {
            var model = Business.Sitemap.Index.SaveNode(input);
            return Json(model);
        }

        public JsonResult DeleteNode(int NodeID)
        {
            Business.Sitemap.Index.DeleteNode(NodeID);

            return Json(new { status = true });
        }


        [AppendLayoutViewModel]
        public ActionResult Web()
        {
            var model = Business.Sitemap.Web.PageLoad();
            ViewBag.Message = Request["msg"];
            return View(model);
        }

        public JsonResult WebTopUpdate(Adams.Admin.DataTransfer.Sitemap.Web.UpdateTopInput input)
        {
            Business.Sitemap.Web.UpdateTop(input);
            return Json(new { success = 1 });
        }

        public JsonResult WebTopGetNode(Adams.Admin.DataTransfer.Sitemap.Web.GetTopNodeInput input)
        {
            var model = Business.Sitemap.Web.GetTopNode(input);
            return Json(model);
        }

        public JsonResult WebSaveTopNode(Adams.Admin.DataTransfer.Sitemap.Web.NodeTopFormInput input)
        {
            var model = Business.Sitemap.Web.SaveTopNode(input);
            return Json(model);
        }

        public JsonResult WebDeleteTopNode(int NodeID)
        {
            Business.Sitemap.Web.DeleteTopNode(NodeID);

            return Json(new { status = true });
        }

        public JsonResult WebLeftUpdate(Adams.Admin.DataTransfer.Sitemap.Web.UpdateLeftInput input)
        {
            Business.Sitemap.Web.UpdateLeft(input);
            return Json(new { success = 1 });
        }

        public JsonResult WebLeftGetNode(Adams.Admin.DataTransfer.Sitemap.Web.GetLeftNodeInput input)
        {
            var model = Business.Sitemap.Web.GetLeftNode(input);
            return Json(model);
        }

        public JsonResult WebSaveLeftNode(Adams.Admin.DataTransfer.Sitemap.Web.NodeLeftFormInput input)
        {
            var model = Business.Sitemap.Web.SaveLeftNode(input);
            return Json(model);
        }

        public JsonResult WebDeleteLeftNode(int NodeID)
        {
            Business.Sitemap.Web.DeleteLeftNode(NodeID);

            return Json(new { status = true });
        }

        public JsonResult WebBottomUpdate(Adams.Admin.DataTransfer.Sitemap.Web.UpdateBottomInput input)
        {
            Business.Sitemap.Web.UpdateBottom(input);
            return Json(new { success = 1 });
        }

        public JsonResult WebBottomGetNode(Adams.Admin.DataTransfer.Sitemap.Web.GetBottomNodeInput input)
        {
            var model = Business.Sitemap.Web.GetBottomNode(input);
            return Json(model);
        }

        public JsonResult WebSaveBottomNode(Adams.Admin.DataTransfer.Sitemap.Web.NodeBottomFormInput input)
        {
            var model = Business.Sitemap.Web.SaveBottomNode(input);
            return Json(model);
        }

        public JsonResult WebDeleteBottomNode(int NodeID)
        {
            Business.Sitemap.Web.DeleteBottomNode(NodeID);

            return Json(new { status = true });
        }

        [AppendLayoutViewModel]
        public ActionResult Mobile()
        {
            var model = Business.Sitemap.Mobile.PageLoad();
            ViewBag.Message = Request["msg"];
            return View(model);
        }

        public JsonResult MobileUpdate(Adams.Admin.DataTransfer.Sitemap.Mobile.UpdateInput input)
        {
            Business.Sitemap.Mobile.Update(input);
            return Json(new { success = 1 });
        }

        public JsonResult MobileGetNode(Adams.Admin.DataTransfer.Sitemap.Mobile.GetNodeInput input)
        {
            var model = Business.Sitemap.Mobile.GetNode(input);
            return Json(model);
        }

        public JsonResult MobileSaveNode(Adams.Admin.DataTransfer.Sitemap.Mobile.MobileNodeFormInput input)
        {
            var model = Business.Sitemap.Mobile.SaveNode(input);
            return Json(model);
        }

        public JsonResult MobileDeleteNode(int NodeID)
        {
            Business.Sitemap.Mobile.DeleteNode(NodeID);

            return Json(new { status = true });
        }
    }
}
